<?php

namespace app\manystore\model;

use think\Model;


class GoodsCustomer extends Model
{

    

    

    // 表名
    protected $name = 'goods_customer';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'gender_text'
    ];
    

    
    public function getGenderList()
    {
        return ['1' => __('Gender 1'), '0' => __('Gender 0')];
    }


    public function getGenderTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
        $list = $this->getGenderList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function manystoreshop()
    {
        return $this->belongsTo('ManystoreShop', 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function manystore()
    {
        return $this->belongsTo('Manystore', 'store_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function branchofficeoffice()
    {
        return $this->belongsTo('BranchofficeOffice', 'office_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
    public function goods()
    {
        return $this->belongsTo('Goods', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

}
